<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
  
  // AJAX kiểm tra thông tin id nhập
  /*
  function checkCode(str,id) {
    if (str=="") {
      document.getElementById("ajax").innerHTML="";
      return;
    }	
    if (window.XMLHttpRequest) {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
    } else { // code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
	
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
        document.getElementById("ajax").innerHTML=xmlhttp.responseText;
      }      
    }
    xmlhttp.open("GET","http://localhost/aothun/util/export.php?q="+str+"&id="+id,true);
    xmlhttp.send();        
  }   

  /*
  function thongTinKho()
  {
    if(document.getElementById('thong_tin_kho').style.display == "none")
    {
      document.getElementById('thong_tin_kho').style.display = "block";
    }
    else
    {
      document.getElementById('thong_tin_kho').style.display = "none"
    }
  }

  
  $(function(){
		 $("input.form-control").keypress(function(e){
			var storage = $("#storageInput").val();
			 // lay code
			 var code = $("#codeInput").val();			 
			 // lay data tu storage
			 var storage_tmp = storage + "|" + code;
			 // lay storage id 
			 var storage_id = $("#storageId").val();			 
			 // goi code
			 checkCode(storage_tmp,storage_id);
			 // luu gia tri vao storage
			 $("#storageInput").val(storage_tmp);			 			 			 
			 // xoa gia tri code
			 $("#codeInput").val("");	
			 // an div xu ly code
			 $('#storageTable').hide();
			 
			 var k=e.keyCode || e.which;
			 if(k==13){
				 e.preventDefault();
			 }			
		 });
	 });  
	*/
</script>
<?=isset($quantityCodeMsg) ? $quantityCodeMsg : "" ?>
<?=isset($notify) ? $notify : "" ?>
<?=isset($warning) ? '<div class="alert alert-danger">'.$warning.'</div>' : "" ?>
<form class="form-horizontal" role="form" method="post" action="<?=site_url('exportw/export_process/'.$storage_id.'/'.$code) ?>">  
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label"></label>    
    <div class="col-sm-10">
      Kho <?=$storage->title ?> <span class="badge"><?=$storage->left_quantity ?></span>
      <button type="button" class="btn btn-info" onclick="thongTinKho()">Xem thông tin kho</button>
    </div>
  </div>    
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Nhập code</label>
    <div class="col-sm-10">
      <input id="codeInput" type="text" name="code_input" class="form-control" placeholder="Nhập code sau đó nhấn Enter" name="color" value="">
    </div>
  </div>    
  <input id="storageInput" type="hidden" name="storage" value="" />  
  <input id="storageId" type="hidden" name="storageId" value="<?=$storage->id ?>" /> 
  <input type="hidden" name="codesInput" value="<?=isset($codes_input) ? $codes_input : "" ?>" />
</form>

<?php  
	if(isset($codes_shown) && !empty($codes_shown)):
?>
<form method="post" action="<?=site_url('exportw/remove/'.$storage_id.'/'.$code); ?>">
<div class="table-responsive">
<table id="thong_tin_kho" class="table">
    <thead>
      <tr>
        <td>Mã sản phẩm</td>
        <td>Mã</td>
		<td>Màu</td>
		<td>Size</td>		
        <td>Xóa</td>
      </tr>
    </thead>
    <tbody>
    <?php 
      if(isset($codes_shown) && !empty($codes_shown)):
      foreach($codes_shown as $key => $info): 
    ?>
      <tr>
        <td><?=$info['product'] ?></td>
        <td><?=$info['code'] ?></td>
		<td><?=$info['color'] ?></td>
		<td><?=$info['size'] ?></td>		
        <td><button type="submit" name="removeExportBtn" value="<?=$key ?>" class="btn btn-info">Xóa</button></td>
      </tr>
    <?php 
      endforeach; 
      endif;
    ?>
    </tbody>
</table>
</div>
<input type="hidden" name="codesInputE" value="<?=isset($codesInputE) ? $codesInputE : "" ?>" />
</form>
<?php endif; ?>

<?php if(isset($is_export_form) && !empty($is_export_form)): ?>
<form action="<?=site_url('exportw/make_export_form/'.$storage_id.'/'.$code); ?>" method="post">
	<input type="hidden" name="codesInputE" value="<?=isset($codesInputE) ? $codesInputE : "" ?>" />
	<button type="submit" name="exportFormBtn" value="" class="btn btn-info">Lập phiếu xuất kho</button>
</form>
<?php endif; ?>